
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property({
        type: cc.Node,
        displayName: '确认按钮'
    })
    confirmBtn: cc.Node;

    @property(cc.Sprite)
    goodSprite: cc.Sprite

    @property(cc.Label)
    goodNameLabel: cc.Label

    @property(cc.Label)
    goodPriceLabel: cc.Label

    @property(cc.Label)
    accountAmountLabel: cc.Label

    protected goodId: number

    start() {

    }

    init(data: any = {}) {
        this.goodId = data.id
        this.goodSprite.spriteFrame = data.image
        this.goodNameLabel.string = data.title
        this.goodPriceLabel.string = data.price
        this.accountAmountLabel.string = data.userAmount || '0.00'
        if (typeof data.onConfirm === "function") {
            this.confirmBtn.on(cc.Node.EventType.TOUCH_START, data.onConfirm.bind(data.target || this, this.goodId))
        }
    }
}
